// components/author/author.js
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        item:Object
    },
    /**
     * 组件的初始数据
     */
    data: {

    },
   

    /**
     * 组件的方法列表
     */
    methods: {
        toExpertDetails(events) {
            let temp = events.currentTarget.dataset.item;
            let item = {
                id:temp.userId,
                avatar:temp.avatar,
                nickName:temp.nickName
            }
            console.log(item);
            item = encodeURIComponent(JSON.stringify(item)) 
            wx.navigateTo({
                url: '/pages/expertDetails/expertDetails?item='+item
            })
        },
        addfriend(events) {
            let id = events.currentTarget.dataset.id
            wx.request({
                url: 'http://' + ipconfig + ':8080/mini/addFriend',
                data: {'userAId':wx.getStorageSync('userInfo').id,'userBId':id},
                method: 'POST',
                header: {
                    'Authorization': wx.getStorageSync('token')
                },
                success: function (res) {
                    console.log(res);
                    wx.showToast({
                        title: '申请好友成功',
                    })
                },
                fail: function (err) {
                    console.log(err);
                }
            })
        },
    }
})
